<template>
  <el-dialog :title="title"
             width="700px"
             :close-on-click-modal="false"
             @close="$emit('close')" :visible.sync="visible">
    <el-form :model="form" size="mini" ref="form" label-width="150px">
      <el-form-item label="PNR">
        {{data.pnr}}
      </el-form-item>
      <el-form-item label="最晚取消PNR时间">
        {{data.latestCancelPnrTime | datetimeShortFormat1}}
      </el-form-item>
      <el-form-item label="Office号" prop="officeNo">
        <el-select v-model="form.officeNo" class="w160">
          <el-option v-for="item in options.officeNo" :value="item.key" :key="item.key" :label="item.cname"/>
        </el-select>
      </el-form-item>
      <el-form-item label="备注">
        <el-input type="textarea" v-model="form.remark" :autosize="{ minRows: 4, maxRows: 8}" class="w450"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="center-box">
      <el-button @click="visible = false">关 闭</el-button>
      <easy-button type="primary" @click="onCancelPnr">取消PNR</easy-button>
      <easy-button type="primary" @click="onWaitRefund">下一步，待提交退票</easy-button>
    </div>
  </el-dialog>
</template>

<script>
import Dict from '@/constants/Dict'
export default {
  name: 'CancelPnrDialog',
  props: {
    data: {
      type: Object,
      default () {
        return {
          latestCancelPnrTime: '',
          refundId: '',
          pnr: '',
          officeNo: ''
        }
      }
    }
  },
  data () {
    return {
      title: '处理退票单',
      visible: true,
      options: {
        officeNo: Dict.Options.officeNo
      },
      form: {
        refundId: this.data.refundId,
        remark: null,
        officeNo: this.data.officeNo
      }
    }
  },
  created () {
  },
  methods: {
    onCancelPnr (done) {
      this.$service.airRefund.cancelPnr(this.form).then(() => {
        this.$emit('ok')
        this.visible = false
      }).finally(done)
    },
    onWaitRefund (done) {
      this.$service.airRefund.toSubmitAirline(this.form).then(() => {
        this.$emit('ok')
        this.visible = false
      }).finally(done)
    }
  }
}
</script>

<style scoped>
.pnr-panel {
  padding: 10px;
  border: 1px solid #aee7fb;
}

.pnr-col {
  display: inline-block;
  box-sizing: border-box;
  padding: 0 10px;
}
</style>
